﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutEntrenador.cshtml";
}

@model IEnumerable<Cliente_DozenContext.Cliente_Cliente>
<div>
@{ 
    GridEditMode mode = (GridEditMode)ViewData["mode"];
    GridButtonType type = (GridButtonType)ViewData["type"];  
            @(Html.Telerik().Grid(Model).Name("GRID")
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.Cliente_ClienteCod).Filterable(false);
                        columns.Bound(o => o.Cliente_ClienteNombre);
                        columns.Bound(o => o.Cliente_ClienteApellidos);
                        columns.Bound(o => o.Cliente_Plan.Cliente_PlanNombre);
                        columns.Bound(o => o.Cliente_ClienteFechaPago);
                    })
                                        //.DataBinding(dataBinding => dataBinding.Server()
                                        //        .Select("Index", "GridBuscarCliente", new { mode = mode, type = type })
                                        //)
                                        .DataBinding(dataBinding => dataBinding.Ajax().Select("_Listar", "GridBuscarCliente"))
                                        .ClientEvents(events => events.OnRowSelected("onRowSelected"))

                                        .DataKeys(keys => keys.Add(m => m.Cliente_ClienteCod))
                                        .Scrollable(scrolling => scrolling.Enabled(true))
                                        .Pageable(paging => paging.Enabled(true))
                                        .Footer(true)
                                                .Filterable()
                                                .Selectable()


                                ) 

    }
<div>

<script type="text/javascript">
    function onRowSelected(e) {
        var ordersGrid = $('#Orders').data('tGrid');
        customerID = e.row.cells[0].innerHTML;
        document.location.href = "../../Home/Aikido?id" + customerID;  
//       //  update ui text
//        $('#customerID').text(customerID);

//      //   rebind the related grid
//        ordersGrid.rebind({
//            customerID: customerID
//        });
    }
</script>

